﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace daStaticAnalyser.Analysers
{
    using daStaticAnalyser;
    using daBase.Objects;
    using daBase.Analyser;
    using daSyntaxAnalyser;
    using daSyntaxAnalyser.SyntaxTree;

    [AnalyserDefaultSettings("Метрика Вудворда", "test", 0, "test")]
    class WoodwordAnalyzer : BaseStaticAnalyser
    {
        protected override void DoAnalyse(SyntaxTreeArgs e)
        {
            String MethodName = "";
            if (CheckMethod_GetName(e, out MethodName))
            {
                OuterMethodElement Method = e.Element as OuterMethodElement;
                ControlGraph CG = new ControlGraph();
                CG.Build(Method.Body.Statement);
                int N = 0;
                foreach (var elt in CG.Elements) if (elt is EGLink) N++;
                AddMetric("Метрика Вудворда", N - 1,
                    MethodName,
                    Method.StartInfo.File,
                    Method.StartInfo.Line);
            }
        }
    }

    
}
